package com.baizhi.service.impl;

import com.baizhi.dao.DepartmentDao;
import com.baizhi.entity.Department;
import com.baizhi.service.DepartmentService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DepartmentServiceImpl implements DepartmentService {
    private DepartmentDao departmentDao;
    @Autowired
    public void setDepartmentDao(DepartmentDao departmentDao) {
        this.departmentDao = departmentDao;
    }

    @Override
    public int insert(Department dep) {
        int i = departmentDao.insert(dep);
        return i;
    }

    @Override
    public int delete(Integer did) {
        int i = departmentDao.delete(did);
        return i;
    }

    @Override
    public int deleteAny(int[] dids) {
        int i= departmentDao.deleteAny(dids);
        return i;
    }

    @Override
    public Department selectById(Integer did) {
        Department department = departmentDao.selectById(did);
        return department;
    }

    @Override
    public int update(Department dep) {
        int i = departmentDao.update(dep);
        return i;
    }

    @Override
    public PageInfo<Department> selectByPage(String name,Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Department> list = departmentDao.selectAll(name);
        PageInfo<Department> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public List<Department> selectGetJson() {
        List<Department> list = departmentDao.selectGetJson();
        return list;
    }

    @Override
    public List<Department> selectTriageStatus() {
        List<Department> departments = departmentDao.selectTriageStatus();
        return departments;
    }
}
